package xianhenyuan.csv.utils;

import org.springframework.stereotype.Component;

import java.util.Random;

@Component
public class RandomUtil {

    private final Random random;

    public RandomUtil() {

        random = new Random();
    }

    //获取给定字符串给定长度的随机字符
    public String generateRandomChars(String pattern, int length) {

        StringBuilder sb = new StringBuilder();


        return random.ints(0, pattern.length())
                .mapToObj(pattern::charAt)
                .limit(length)
                .collect(StringBuilder::new, StringBuilder::append, StringBuilder::append)
                .toString();
    }




}
